<!DOCTYPE html>
<html>
<script src="watch.js" type="text/javascript"></script>
<script>
    //defining our object however we like
    var ex1 = {
        attr1: "initial value of attr1",
        attr2: "initial value of attr2"
    };

    var ex2 = [0, 1, 2, 3];

    //defining a 'watcher' for an attribute
    //watch(ex1, "attr1", function() {
    //	console.log("attr1 changed!");
    //});

    //defining a 'watcher' for an attribute
    watch(ex1, function (x) {
        console.log(x);
    }, 3);

    //console.log(Array.prototype.push);

    ex1.attr3 = 1;

    var ex3 = function (name, job, born) {
        this.name = name;
        this.job = job;
        this.born = born;
    }

    var ex4 = new ex3("Bill Gates", "Engineer", 1985);
    console.log(typeof ex4)
    console.log(ex4.constructor)
    //when changing the attribute its watcher will be invoked
    //ex1.attr1 = "other value";
</script>
</html>

